package com.xpgk.mvc.ddc.statistic;


import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.xpgk.annotation.Service;
import com.xpgk.mvc.base.BaseService;

@Service(name = DailyStasticService.serviceName)
public class DailyStasticService  extends  BaseService{
	
	public static final String serviceName = "dailyStasticService";
	
	
	public  Boolean  saveDailyStastic(String organids,String organname,String bussdate,String businesstype,String status){
		Boolean flag = false;
		List<Record> list = Db.find("select *  from ddc_dailystastic where organids = ? and bussdate = ?", organids, bussdate);
		if(list.size() == 0){
			DailyStastic ds = new DailyStastic();
			ds.set(DailyStastic.column_ORGANIDS, organids);
			ds.set(DailyStastic.column_ORGANNAME, organname);
			ds.set(DailyStastic.column_BUSSDATE, bussdate);
			if(businesstype == "1"){
				if(status == "1"){
					ds.set(DailyStastic.column_ZCSL, "1");
				}else if(status == "2"){
					ds.set(DailyStastic.column_ZCLQ, "1");
				}else if(status == "3"){
					ds.set(DailyStastic.column_ZCZZ, "1");
				}else if(status == "4"){
					ds.set(DailyStastic.column_ZCGD, "1");
				}
			}else if(businesstype == "2"){
				if(status == "1"){
					ds.set(DailyStastic.column_ZYSL, "1");
				}else if(status == "2"){
					ds.set(DailyStastic.column_ZYLQ, "1");
				}else if(status == "3"){
					ds.set(DailyStastic.column_ZYZZ, "1");
				}else if(status == "4"){
					ds.set(DailyStastic.column_ZYGD, "1");
				}
			}else if(businesstype == "3"){
				if(status == "1"){
					ds.set(DailyStastic.column_BGSL, "1");
				}else if(status == "2"){
					ds.set(DailyStastic.column_BGLQ, "1");
				}else if(status == "3"){
					ds.set(DailyStastic.column_BGZZ, "1");
				}else if(status == "4"){
					ds.set(DailyStastic.column_BGGD, "1");
				}
			}else if(businesstype == "4"){
				if(status == "1"){
					ds.set(DailyStastic.column_ZXSL, "1");
				}else if(status == "4"){
					ds.set(DailyStastic.column_ZXGD, "1");
				}
			}else if(businesstype == "5"){
				if(status == "1"){
					ds.set(DailyStastic.column_BHPSL, "1");
				}else if(status == "2"){
					ds.set(DailyStastic.column_BHPLQ, "1");
				}else if(status == "3"){
					ds.set(DailyStastic.column_BHPZZ, "1");
				}else if(status == "4"){
					ds.set(DailyStastic.column_BHPGD, "1");
				}
			}else if(businesstype == "6"){
				if(status == "1"){
					ds.set(DailyStastic.column_BZJSL, "1");
				}else if(status == "2"){
					ds.set(DailyStastic.column_BZJLQ, "1");
				}else if(status == "3"){
					ds.set(DailyStastic.column_BZJZZ, "1");
				}else if(status == "4"){
					ds.set(DailyStastic.column_BZJGD, "1");
				}
			}
			flag = ds.save();
		}else{
			Record record = list.get(0);
			DailyStastic ds = DailyStastic.dao.findById(record.get("IDS"));
			if(businesstype == "1"){
				if(status == "1"){
					ds.set(DailyStastic.column_ZCSL, Integer.parseInt(ds.getStr("ZCSL"))+1);
				}else if(status == "2"){
					ds.set(DailyStastic.column_ZCLQ, Integer.parseInt(ds.getStr("ZCLQ"))+1);
				}else if(status == "3"){
					ds.set(DailyStastic.column_ZCZZ, Integer.parseInt(ds.getStr("ZCZZ"))+1);
				}else if(status == "4"){
					ds.set(DailyStastic.column_ZCGD, Integer.parseInt(ds.getStr("ZCGD"))+1);
				}
			}else if(businesstype == "2"){
				if(status == "1"){
					ds.set(DailyStastic.column_ZYSL, Integer.parseInt(ds.getStr("ZYSL"))+1);
				}else if(status == "2"){
					ds.set(DailyStastic.column_ZYLQ, Integer.parseInt(ds.getStr("ZYLQ"))+1);
				}else if(status == "3"){
					ds.set(DailyStastic.column_ZYZZ, Integer.parseInt(ds.getStr("ZYZZ"))+1);
				}else if(status == "4"){
					ds.set(DailyStastic.column_ZYGD, Integer.parseInt(ds.getStr("ZYGD"))+1);
				}
			}else if(businesstype == "3"){
				if(status == "1"){
					ds.set(DailyStastic.column_BGSL, Integer.parseInt(ds.getStr("BGSL"))+1);
				}else if(status == "2"){
					ds.set(DailyStastic.column_BGLQ, Integer.parseInt(ds.getStr("BGLQ"))+1);
				}else if(status == "3"){
					ds.set(DailyStastic.column_BGZZ, Integer.parseInt(ds.getStr("BGZZ"))+1);
				}else if(status == "4"){
					ds.set(DailyStastic.column_BGGD, Integer.parseInt(ds.getStr("BGGD"))+1);
				}
			}else if(businesstype == "4"){
				if(status == "1"){
					ds.set(DailyStastic.column_ZXSL, Integer.parseInt(ds.getStr("ZXSL"))+1);
				}else if(status == "4"){
					ds.set(DailyStastic.column_ZXGD, Integer.parseInt(ds.getStr("ZXGD"))+1);
				}
			}else if(businesstype == "5"){
				if(status == "1"){
					ds.set(DailyStastic.column_BHPSL, Integer.parseInt(ds.getStr("BHPSL"))+1);
				}else if(status == "2"){
					ds.set(DailyStastic.column_BHPLQ, Integer.parseInt(ds.getStr("BHPLQ"))+1);
				}else if(status == "3"){
					ds.set(DailyStastic.column_BHPZZ, Integer.parseInt(ds.getStr("BHPZZ"))+1);
				}else if(status == "4"){
					ds.set(DailyStastic.column_BHPGD, Integer.parseInt(ds.getStr("BHPGD"))+1);
				}
			}else if(businesstype == "6"){
				if(status == "1"){
					ds.set(DailyStastic.column_BZJSL, Integer.parseInt(ds.getStr("BZJSL"))+1);
				}else if(status == "2"){
					ds.set(DailyStastic.column_BZJLQ, Integer.parseInt(ds.getStr("BZJLQ"))+1);
				}else if(status == "3"){
					ds.set(DailyStastic.column_BZJZZ, Integer.parseInt(ds.getStr("BZJZZ"))+1);
				}else if(status == "4"){
					ds.set(DailyStastic.column_BZJGD, Integer.parseInt(ds.getStr("BZJGD"))+1);
				}
			}
			flag = ds.update();
		}
		return flag;
	}
}
